package com.share.device.controller;


import com.share.common.core.web.controller.BaseController;
import com.share.common.core.web.domain.AjaxResult;
import com.share.common.core.web.page.TableDataInfo;
import com.share.device.domain.Station;
import com.share.device.service.IStationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 站点表 前端控制器
 * </p>
 *
 * @author pww
 * @since 2025-03-25
 */
@Tag(name = "站点接口管理")
@RestController
@RequestMapping("/station")
public class StationController extends BaseController {
    @Autowired
    private IStationService stationService;


    /**
     * 设置站点数据
     * @param station
     * @return
     */
    @Operation(summary = "设置站点数据")
    @PostMapping("/setData")
     public AjaxResult setDate(@RequestBody Station station){
        return toAjax(stationService.setData(station));
    }



    /**
     * 删除站点
     *
     * @param ids
     * @return
     */
    @Operation(summary = "删除站点")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids){
        return toAjax(stationService.removeStationByIds(ids));
    }


    /**
     * 查询站点详情
     *
     * @param id
     * @return
     */
    @Operation(summary = "查询站点详情")
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable Long id) {
        return AjaxResult.success(stationService.getById(id));
    }


    /**
     * 修改站点
     *
     * @param station
     * @return
     */
    @PutMapping
    @Operation(summary = "修改站点")
    public AjaxResult edit(@RequestBody Station station) {
        return toAjax(stationService.updateStation(station));
    }

    /**
     * 新增站点
     *
     * @param station
     * @return
     */

    @PostMapping
    @Operation(summary = "新增站点")
    public AjaxResult add(@RequestBody Station station) {
        return toAjax(stationService.saveStation(station));
    }


    /**
     * 查询站点列表
     */
    @GetMapping("/list")
    @Operation(summary = "查询站点列表")
    public TableDataInfo list(Station station) {
        startPage();
        List<Station> list = stationService.selectStationList(station);
        return getDataTable(list);
    }


}
